package com.oak.broke.exception.handler;

import com.oak.broke.constant.ResponseConstant;
import com.oak.broke.model.vip.base.ResponseMessage;
import com.oak.broke.utils.MessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author tanghan
 * @Description 其他异常处理
 * @date 2023/04/13/ 14:37:00
 */
@Slf4j
@RestControllerAdvice
@Order(99)
public class CommonExceptionHandler {

    /**
     * 其他异常处理
     *
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    public ResponseMessage handleException(Exception e) {
        log.error("系统异常，原因:{}，堆栈信息", e.getMessage(), e);
        return ResponseMessage.fail(ResponseConstant.SYSTEM_INTERNAL_EXCEPTION, MessageUtil.getMessage(ResponseConstant.SYSTEM_INTERNAL_EXCEPTION));
    }
}
